﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChessOnlineServiceTest
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.WriteLine("Name: ");
            //string name = Console.ReadLine();
            //Console.WriteLine("Password: ");
            //string password = Console.ReadLine();
            //ChessOnlineService.ChessOnlineServiceClient cl = new ChessOnlineService.ChessOnlineServiceClient();
            //cl.LogInCompleted += new EventHandler<ChessOnlineService.LogInCompletedEventArgs>(LogInCompleted);
            //string hash_code = cl.LogIn(name, password);

            while (true)
            {
                StartEmptyAuthorizationTest();
                //string isAuthenticated = //cl.IsAuthorized(""/*hash_code*/);

                //if (isAuthenticated == "true")
                //{
                //    Console.WriteLine("Successfuly authenticated!");
                //}
                //else
                //{
                //    Console.WriteLine("Failed.");
                //}
            }

            Console.ReadLine();
        }

        static void StartEmptyAuthorizationTest()
        {
            ChessOnlineService.ChessOnlineServiceClient cl = new ChessOnlineService.ChessOnlineServiceClient();
            cl.IsAuthorizedCompleted += new EventHandler<ChessOnlineService.IsAuthorizedCompletedEventArgs>(IsAuthorizedCompleted);
            cl.IsAuthorizedAsync("");
        }

        static void LogInCompleted(object sender, ChessOnlineService.LogInCompletedEventArgs e)
        {
            ChessOnlineService.ChessOnlineServiceClient cl = new ChessOnlineService.ChessOnlineServiceClient();
            cl.IsAuthorizedCompleted += new EventHandler<ChessOnlineService.IsAuthorizedCompletedEventArgs>(IsAuthorizedCompleted);
            cl.IsAuthorizedAsync("");
        }

        static public void IsAuthorizedCompleted(object sender, ChessOnlineService.IsAuthorizedCompletedEventArgs args)
        {
            if (args.Result == "true")
            {
                Console.WriteLine("Successfuly authenticated!");
            }
            else
            {
                Console.WriteLine("Failed.");
            }
        }
    }
}
